package com.spider.im.chat.model;

import java.net.URL;
import java.time.LocalDateTime;


import lombok.Setter;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ChatMessage {
    private Long id;
    private Long senderId;
    private Long receiverId;
    private String message;  // 文本内容（可选）
    private String messageType;  // 消息类型 (text, image, audio, video, file)
    private String fileUrl;  // 文件 URL（如果是图片、音频、视频、文件）
    private String senderStatus;
    private String receiverStatus;
    private LocalDateTime createdAt;

    // 构造方法
    public ChatMessage(Long senderId, Long receiverId, String message, String messageType, String fileUrl) {
        this.senderId = senderId;
        this.receiverId = receiverId;
        this.message = message;
        this.messageType = messageType;
        this.fileUrl = fileUrl;
        this.senderStatus = "normal";
        this.receiverStatus = "unread";
        this.createdAt = LocalDateTime.now();
    }

    // 校验消息类型是否合法
    private boolean isValidMessageType(String messageType) {
        return messageType != null &&
                (messageType.equals("text") || messageType.equals("image") ||
                        messageType.equals("audio") || messageType.equals("video") ||
                        messageType.equals("file"));
    }

}
